home *** CD-ROM | disk | FTP | other *** search
- #if !defined(FWFILESY_H) && !defined(__ODFRC__)
- #define FWFILESY_H
- //========================================================================================
- //
- // File: FWFileSy.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- #ifndef FWPRIEXC_H
- #include "FWPriExc.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__FILES__)
- #include "Files.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__ERRORS__)
- #include "Errors.h"
- #endif
-
- #ifdef FW_BUILD_WIN16
- // WINVER 0x30a
- #include <windows.h>
- #endif
-
- #ifdef FW_BUILD_WIN32
- #include <winerror.h>
- #include <winbase.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Platform Error constants
- //========================================================================================
-
- const FW_PlatformError FW_xCantDeleteWorkingDirectory = -30010; // !!!JEL need offical value
- const FW_PlatformError FW_xInvalidDirectory = -30011; // !!!JEL need offical value
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
- class FW_CFileSpecification;
- class FW_CDirectorySpecification;
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- #ifdef FW_BUILD_WIN16
- typedef HFILE FW_FileAccessHandle;
- #endif
-
- #ifdef FW_BUILD_WIN32
- typedef HANDLE FW_FileAccessHandle;
- #endif
-
- #ifdef FW_BUILD_MAC
- typedef short FW_FileAccessHandle;
- const OSType FW_kDefaultFileType = 'TEXT';
- const OSType FW_kDefaultCreatorType = 'ttxt';
- #endif
-
- const FW_FileAccessHandle FW_kInvalidAccessHandle = (FW_FileAccessHandle)(-1);
- const long FW_kInvalidSeek = -1;
-
-
- //========================================================================================
- // FW_CAccessPermission
- //
- // Static class which defines some FWCommon file operations. Should be nested inside of
- // FW_PFile, but CFront was having troubles.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CAccessPermission
- {
- public:
- #ifdef FW_BUILD_MAC
- enum Access
- {
- kRead = fsRdPerm,
- kWrite = fsWrPerm,
- kReadWrite = fsRdWrPerm
- };
-
- // Mac defines these constants as bit positions.
- enum Deny
- {
- kDenyNone = 0x00,
- kDenyRead = 0x10,
- kDenyWrite = 0x20,
- kDenyReadWrite = 0x30
- };
- #endif
- #ifdef FW_BUILD_WIN16
- enum Access
- {
- kRead = OF_READ,
- kWrite = OF_WRITE,
- kReadWrite = OF_READWRITE
- };
-
-
- enum Deny
- {
- kDenyNone = OF_SHARE_DENY_NONE,
- kDenyRead = OF_SHARE_DENY_READ,
- kDenyWrite = OF_SHARE_DENY_WRITE,
- kDenyReadWrite = OF_SHARE_EXCLUSIVE
- };
- #endif
-
-
- #ifdef FW_BUILD_WIN32
- enum Access
- {
- kRead = GENERIC_READ,
- kWrite = GENERIC_WRITE,
- kReadWrite = GENERIC_READ | GENERIC_WRITE
- };
-
-
- enum Deny
- {
- kDenyNone = FILE_SHARE_READ | FILE_SHARE_WRITE,
- kDenyRead = FILE_SHARE_WRITE,
- kDenyWrite = FILE_SHARE_READ,
- kDenyReadWrite = 0
- };
- #endif
-
- FW_CAccessPermission(Access access = kReadWrite,
- Deny deny = kDenyReadWrite);
- // Main constructor, sets up the specified access priveleges. Default privelege
- // is exclusive read/write access.
-
- FW_CAccessPermission(const FW_CAccessPermission& permission);
- // Copy constructor
-
- ~FW_CAccessPermission();
-
-
- void GetPermission(Access& access,
- Deny& deny) const;
- // Returns the priveleges this class specifies.
-
-
- //===========================================================
- // Operators
- //===========================================================
-
- FW_CAccessPermission& operator=(const FW_CAccessPermission& permission);
- // Assignment operator.
-
- FW_Boolean operator==(const FW_CAccessPermission& permission) const;
- // Equality operator.
-
- FW_Boolean operator!=(const FW_CAccessPermission& permission) const;
- // Inequality operator.
-
- private:
- Access fAccess;
- Deny fDeny;
- };
-
-
- //========================================================================================
- // FW_PFile
- //
- // Static class which defines some FWCommon file operations.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CFileSystem
- {
- public:
- typedef short FileError;
-
- static void CreateFile(const FW_CFileSpecification& fileSpec, FW_Boolean overWriteExisting = FALSE);
- // Creates the file specified by fileSpec. If the file already exists and
- // overWriteExisting is TRUE, then the file will be truncated to zero-length.
- // Otherwise, the file will be left alone.
-
- static void DeleteFile(const FW_CFileSpecification& fileSpec);
- // Deletes the file specified by fileSpec. WARNING: This action cannot be undone.
-
- static void CreateDirectory(const FW_CDirectorySpecification& directory);
- // Creates the directory specified by directory. If the directory already
- // exists, then nothing is done.
-
- static void DeleteDirectory(const FW_CDirectorySpecification& directory);
- // Deletes the directory specified by directory. This routine will only
- // delete an empty directory. The user must make sure that there are no
- // files left in the directory. The directory must also not be the current
- // working directory for it to be deleted. Use SetCurrentDirectory to set
- // another directory if this is the case.
-
- static void GetCurrentDirectory(FW_CDirectorySpecification& directory);
- // Sets directory to point to the current default directory.
-
- static void SetCurrentDirectory(const FW_CDirectorySpecification& directory);
- // Set the current working directory.
-
- static FW_Boolean IsValidDirectory(const FW_CDirectorySpecification& directory);
- // Returns TRUE if the specified directory exists.
-
- static FW_Boolean IsValidDrive(const FW_CString& driveName);
- // Returns TRUE if the specified drive exists.
-
- static FW_Boolean IsValidFile(const FW_CFileSpecification& theFile);
- // Tests the existence of a file.
-
- private:
- #ifdef FW_BUILD_WIN16
- static FW_CFileSystem::FileError PrivWinPrimitiveSetCurrentDir(const FW_Char* dirName,
- short driveNumber);
- static FW_CFileSystem::FileError PrivWinPrimitiveDeleteDir(const FW_Char* dirName);
- static FW_CFileSystem::FileError PrivWinPrimitiveCreateDir(const FW_Char* dirName);
- #endif
-
- FW_CFileSystem() {}
- // This is a package class.
-
- public:
- #ifdef FW_BUILD_WIN
- static FW_Boolean WinPathExists(const FW_CString& pathName);
- // Tests the existence of a particular path and/or filename. Paths should NOT
- // be terminated with a path delimiter.
- #endif
-
-
- #ifdef FW_BUILD_WIN16
- enum MoveMethods
- {
- kFromStart = 0,
- kFromCurrent = 1,
- kFromEnd = 2
- };
- #endif
-
- #ifdef FW_BUILD_WIN32
- enum MoveMethods
- {
- kFromStart = FILE_BEGIN,
- kFromCurrent = FILE_CURRENT,
- kFromEnd = FILE_END
- };
- #endif
-
-
- #ifdef FW_BUILD_WIN16
- enum FW_ErrorCodes
- {
- kNoError = 0,
- kBadFileName = 123,
- kDirectoryBusy = 16,
- kDirectoryFull = 82,
- kDiskFull = 39,
- kEndOfFileReached = 38,
- kFileExists = 80,
- kFileLocked = 33,
- kNoFileFound = 2,
- kFileNotOpen = 1006,
- kGeneralIOError = 31,
- kInvalidAccess = 12,
- kInvalidFileReference = 6,
- kNoSuchVolume = 15,
- kParameterError = 87,
- kPathNotFound = 3,
- kPermissionError = 5,
- kReadFault = 30,
- kSeekError = 25,
- kSharingViolation = 32,
- kTooManyOpenFiles = 4,
- kWriteFault = 29,
- kWriteProtect = 19
- };
- #endif
-
- #ifdef FW_BUILD_WIN32
- enum FW_ErrorCodes
- {
- kNoError = NO_ERROR,
- kBadFileName = ERROR_INVALID_NAME,
- kDirectoryBusy = ERROR_CURRENT_DIRECTORY,
- kDirectoryFull = ERROR_CANNOT_MAKE,
- kDiskFull = ERROR_HANDLE_DISK_FULL,
- kEndOfFileReached = ERROR_HANDLE_EOF,
- kFileExists = ERROR_FILE_EXISTS,
- kFileLocked = ERROR_LOCK_VIOLATION,
- kNoFileFound = ERROR_FILE_NOT_FOUND,
- kFileNotOpen = ERROR_FILE_INVALID,
- kGeneralIOError = ERROR_GEN_FAILURE,
- kInvalidAccess = ERROR_INVALID_ACCESS,
- kInvalidFileReference = ERROR_INVALID_HANDLE,
- kNoSuchVolume = ERROR_INVALID_DRIVE,
- kParameterError = ERROR_INVALID_PARAMETER,
- kPathNotFound = ERROR_PATH_NOT_FOUND,
- kPermissionError = ERROR_ACCESS_DENIED,
- kReadFault = ERROR_READ_FAULT,
- kSeekError = ERROR_SEEK,
- kSharingViolation = ERROR_SHARING_VIOLATION,
- kTooManyOpenFiles = ERROR_TOO_MANY_OPEN_FILES,
- kWriteFault = ERROR_WRITE_FAULT,
- kWriteProtect = ERROR_WRITE_PROTECT
- };
-
-
- #endif
-
-
- public:
- #ifdef FW_BUILD_MAC
- enum MoveMethods
- {
- kFromStart = fsFromStart,
- kFromCurrent = fsFromMark,
- kFromEnd = fsFromLEOF
- };
-
- enum FW_ErrorCodes
- {
- kNoError = noErr,
- kAFPAccessDenied = afpAccessDenied,
- kAFPDenyConflict = afpDenyConflict,
- kAFPObjectTypeErr = afpObjectTypeErr,
- kBadFileName = bdNamErr,
- kDirectoryBusy = fBsyErr,
- kDirectoryFull = dirFulErr,
- kDiskFull = dskFulErr,
- kEndOfFileReached = eofErr,
- kFileBusy = fBsyErr,
- kFileExists = dupFNErr,
- kFileLocked = fLckdErr,
- kNoFileFound = fnfErr,
- kFileNotOpen = fnOpnErr,
- kGeneralIOError = ioErr,
- kGetFPosError = gfpErr,
- kInvalidAccess = wrPermErr,
- kInvalidFileReference = rfNumErr,
- kNoSuchVolume = nsvErr,
- kNotAnHFSVolume = wrgVolTypErr,
- kParameterError = paramErr,
- kPathNotFound = dirNFErr,
- kPermissionError = permErr,
- kRenameError = fsRnErr,
- kSeekError = posErr,
- kSharingViolation = opWrErr,
- kTooManyOpenFiles = tmfoErr,
- kVolumeLocked = vLckdErr,
- kWriteProtect = wPrErr
- };
-
- static FW_Boolean MacIsVolumeShared(short volumeRefNum);
- // Returns TRUE if the volume specified by volumeRefNum
- #endif
-
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-
-
-